package org.jtb.quickr;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

abstract class SignedRequest extends FlickrRequest {
    private String secret;
    private AuthResponse.Token authToken;
    
    public SignedRequest(String baseUrl, String apiKey, String secret, AuthResponse.Token authToken) {
        super(baseUrl, apiKey);
        setSecret(secret);
        setAuthToken(authToken);
    }
    
    public abstract FlickrResponse execute() throws QuickrException;
            
    protected Map<String,String> getArgs() {
        if (getAuthToken() != null) {
            putArg("auth_token", getAuthToken().toString());
        }
        
        return super.getArgs();
    }

    protected String getSecret() {
        return secret;
    }

    private void setSecret(String secret) {
        this.secret = secret;
    }

    protected AuthResponse.Token getAuthToken() {
        return authToken;
    }

    private void setAuthToken(AuthResponse.Token authToken) {
        this.authToken = authToken;
    }
}
